package com.abhinav;

public class GarbageCollectionTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ClassA a = new ClassA("white");
		a = null;
		for (int i = 0; i < 10000; i++) {
			if (i % 2 == 1) {
				a = new ClassA("red1 "+i);
			} else {
				a = new ClassA("blue1 "+i);
			}
			a = null;
		}

		Runtime.getRuntime().gc();  
	}

}

class ClassA {
	private String color;

	public ClassA(String color) {
		this.color = color;
	}

	@Override
	public void finalize() {
		System.out.println(this.color + " cleaned");
	}
}
